#include<stdio.h>
#include<unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include<stdlib.h>
#define BUFFER_SIZE 128
int main()
{
    char pathname[BUFFER_SIZE]={0};
/*获取当前进程的工作目录*/
    getcwd(pathname,BUFFER_SIZE);
    printf("pathname=%s\n",pathname);
/*打开文件*/
   DIR *dir=opendir(pathname);
   if(dir==NULL)
   {
        perror("open dir error:");
        exit(-1);
   }
/*读取文件夹*/
while(1)
{
     struct dirent* content=readdir(dir);
     if(content==NULL)
     {
        break;
     }
    printf("name:%s,type:%d\n",content->d_name,content->d_type);
}
/*关闭文件夹*/
closedir(dir);





    return 0;
}